package com.york.tinyrpc.example.consumer;

import com.york.tinyrpc.example.common.model.User;
import com.york.tinyrpc.example.common.service.UserService;
import com.york.tinyrpc.protoss.bootstrap.TinyRpcConsumerBootstrap;
import com.york.tinyrpc.protoss.config.TinyRpcConfig;
import com.york.tinyrpc.protoss.constant.TinyRpcConstants;
import com.york.tinyrpc.protoss.proxy.ServiceProxyFactory;
import com.york.tinyrpc.protoss.utils.ConfigUtils;

import java.util.Date;

/**
 * 简易服务消费者示例
 */
public class EasyConsumerExample {
    public static void main(String[] args) {

        // 启动类启动即可
        TinyRpcConsumerBootstrap.init();
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setName("york");
        // 调用
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getName());
        } else {
            System.out.println("user == null");
        }
        // protoss版本：测试Mock服务是否生效,如果生效为0否则为1
        int number = userService.getNumber();
        System.out.println(number);

        double doubleNumber = userService.getDoubleNumber();
        System.out.println(doubleNumber);

        Double numberDouble = userService.getDouble();
        System.out.println(numberDouble);

        Date date = userService.getDate();
        System.out.println(date);
    }
}
